﻿#include "atlas.h"
#include "plist.h"
#include <io.h>

int main(){
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
		FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);

	cout << "Made in China by 路同学\n扫描 .atlas .plist .png" << endl;
	string path = __argv[0];
	while (true) {
		if (path.back() == '\\') {
			break;
		}
		path.pop_back();
	}

	_finddata_t file_data;
	auto str_temp = path + "*";
	auto handle = _findfirst(str_temp.c_str(), &file_data);
	if (handle == -1L) {
		cout << "not found" << endl;
		return 0;
	}

	do {
		if (file_data.attrib & _A_SUBDIR) {
			continue;
		}
		str_temp = file_data.name;

		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
			FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);

		if (str_temp.find(".atlas") != string::npos) {
			cout << str_temp.substr(0, str_temp.length() - 6) << " ";
			anti_atlas(path, str_temp, true);
		} else if (str_temp.find(".plist") != string::npos) {
			cout << str_temp.substr(0, str_temp.length() - 6) << " ";
			anti_plist(path, str_temp, true);
		}
		
	} while (_findnext(handle, &file_data) == 0);
	_findclose(handle);

	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
		FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	cout << "done.";
	for (;;);
	return 0;
}
